<template>
  <div class="myContainer">
    <el-row class="myBorderBottom myMarginBottom_10px">
      <el-col :span="7" class="myTitleText">基本信息</el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        资产条码 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="资产条码由系统自动生成" v-model="code" disabled></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        资产名称 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="资产名称" v-model="property_name" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        资产分类 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="资产分类" v-model="cate_name" :disabled="readonly" @focus="getCate"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        所属区域 :
      </el-col>
      <el-col :span="6">
        <template>
          <el-cascader
            placeholder="全部项目/小区"
            :disabled="readonly || readonly_update"
            :options="regionOptions"
            v-model="regionOptSelected">
          </el-cascader>
        </template>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        管理员 :
      </el-col>
      <el-col :span="6">
        <template>
          <el-select v-model="admin_name" placeholder="请选择管理员" :disabled="readonly || readonly_update">
            <el-option
              v-for="item in admin_options"
              :key="item.admin_id"
              :label="item.admin_name"
              :value="item.admin_id">
            </el-option>
          </el-select>
        </template>
      </el-col>
    </el-row>

    <!-- <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        使用部门 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="使用部门" :disabled="readonly || readonly_update" v-model="dept_info_name" @focus="handleDeptClick"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        使用人 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="使用人" :disabled="readonly || readonly_update" v-model="dutyName" @focus="onAssign"></el-input>
      </el-col>
    </el-row> -->
  
    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        存放位置 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="存放位置" v-model="property_loc" :readonly="readonly"></el-input>
      </el-col>
    </el-row>
    
    <el-row class="myBorderBottom myMarginBottom_10px">
      <el-col :span="7" class="myTitleText">财务信息</el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        资产来源 :
      </el-col>
      <el-col :span="6">
        <template>
          <el-select v-model="sourceValue" placeholder="资产来源" :disabled="readonly">
            <el-option
              v-for="item in sourceOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-col>
    </el-row>
    
    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        金额 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="金额" v-model="property_money" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        购入时间 :
      </el-col>
      <el-col :span="6">
        <el-date-picker
          v-model="datePicker"
          type="date"
          :disabled="readonly"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="购入时间">
        </el-date-picker>
      </el-col>
    </el-row>
    
    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
        质保时间(月) :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="质保时间(月)" v-model="property_warranty" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        使用年限(月) :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="使用年限(月)" v-model="year_limit" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        供应商 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="供应商" v-model="property_suppliers" :readonly="readonly"></el-input>
      </el-col>
    </el-row>
    
    <el-row class="myBorderBottom myMarginBottom_10px">
      <el-col :span="7" class="myTitleText">规格参数</el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        规格型号 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="规格型号" v-model="property_spec" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        SN号 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="SN号" v-model="property_sn" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        计量单位 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="计量单位" v-model="property_unit" :readonly="readonly"></el-input>
      </el-col>
    </el-row>
    
    <el-row 
      :gutter="10" 
      class="myMarginBottom_10px"
      v-for="(domain, index) in dynamicValidateForm.domains">
      <el-col :span="3" class="myLeftMsg">
        {{domain.attr_name}} :
      </el-col>
      <el-col :span="6">
        <el-input :placeholder="'请输入'+domain.attr_name" v-model="domain.attr_value" :readonly="readonly"></el-input>
      </el-col>
      <el-col :span="2">
        <el-button @click.prevent="removeDomain(domain)" v-if="type=='add'||type=='update'">删除</el-button>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="6" :offset="3">
        <el-popover
          placement="right"
          width="300"
          v-model="visible">
          <el-row class="myBorderBottom myMarginBottom_10px">
            <el-col :span="24" class="myTitleText">添加新属性</el-col>
          </el-row>
          <el-row :gutter="10" class="myMarginBottom_10px">
            <el-col :span="6" class="myLeftMsg">属性名称:</el-col>
            <el-col :span="18">
              <el-input placeholder="属性名称" v-model="attrValue"></el-input>
            </el-col>
          </el-row>
          <el-row style="text-align: right; margin: 0">
            <el-button size="mini" type="text" @click="visible = false">取消</el-button>
            <el-button type="primary" size="mini" @click="attrOK">确定</el-button>
          </el-row>
          <el-button slot="reference" type="primary" icon="el-icon-plus" v-if="type=='add'||type=='update'">添加新属性</el-button><!-- @click="addDomain" -->
        </el-popover>
      </el-col>
    </el-row>

    <el-row class="myBorderBottom myMarginBottom_10px">
      <el-col :span="7" class="myTitleText">其他</el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        图片 :
      </el-col>
      <el-col :span="6">
        <el-upload
          class="avatar-uploader"
          :action="uploadUrl"
          :disabled="readonly"
          :show-file-list="false"
          :before-upload="beforeAvatarUpload"
          :data="postData"
          :on-success="handleAvatarSuccess">
          <img v-if="imageUrl" :src="imageUrl" class="avatar">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        备注 :
      </el-col>
      <el-col :span="6">
        <el-input placeholder="备注" type="textarea" v-model="property_note" :readonly="readonly"></el-input>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="myMarginBottom_10px">
      <el-col :span="6" :offset="3">
        <el-button type="primary" v-if="type=='add'" @click="add">新增</el-button>
        <el-button type="primary" v-if="type=='update'" @click="update">保存</el-button>
        <el-button type="primary" @click="back">返回</el-button>
      </el-col>
    </el-row>
    

    <el-dialog title="选择使用人" class="myRoleDialog" :visible.sync="newRoleDialogVisible" >
      <el-row :gutter="10">
        <el-col :span="20">
          <el-input placeholder="输入关键词" v-model="kw"></el-input>
        </el-col>
        <el-col :span="4" class="myTextAlignRight">
          <el-button type="primary" class="myBgGreen" @click="onSearch">查询</el-button>
        </el-col>
      </el-row>
      <div class="mymarginTop_10px">
        <el-tree
          class="myOV_y_400px" 
          ref="dutyDlg"
          v-loading="dutyDlgListLoading"
          :data="dutyDlgList"
          :props="dutyDlgProps"
          node-key="staff_id"
          @check-change="onChange"
          :render-content="renderContent"
          show-checkbox>
        </el-tree>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" class="myBgGreen" @click="newRoleDialogVisible = false">取 消</el-button>
        <el-button type="primary" class="myBgGreen" @click="onAssignSub">提 交</el-button>
      </div>
    </el-dialog>
    
    <!--选择部门弹出框 start-->
    <el-dialog title="选择部门" class="myRoleDialog" :visible.sync="deptDialogVisible">
      <el-menu class="myOV_y_400px zcgl"
        v-loading="deptLoading"
        :default-active="deptSelected"
        @open="handleDeptSelect"
        @close="handleDeptSelect"
        @select="handleDeptSelect">
          <dept-sub-menu :subMenu='deptList'></dept-sub-menu>
       </el-menu>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" class="myBgGreen" @click="deptDialogVisible = false">取 消</el-button>
        <el-button type="primary" class="myBgGreen" @click="handleDeptDlgClick" >提 交</el-button>
      </div>
    </el-dialog>
    <!--选择部门 end-->  
    

    <el-dialog title="选择资产分类" class="myRoleDialog" :visible.sync="cateDialogVisible">
      <el-tree 
        class="asset myOV_y_400px"
        :data="cateTree" 
        :props="defaultProps"
        default-expand-all
        :expand-on-click-node="false"
        :render-content="renderContentcate" 
        @node-click="handleNodeClick">
      </el-tree>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" class="myBgGreen" @click="cateDialogVisible = false">取 消</el-button>
        <el-button type="primary" class="myBgGreen" @click="handleCateDlgClick" >提 交</el-button>
      </div>
    </el-dialog>

  </div>
</template>     
  
<style scoped>
  .myBorderBottom{
    border-bottom:1px dotted #dbdbdb;
    padding-bottom: 5px;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleText{
    font-weight: 500;
    font-size: 16px;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myPaddingTop_10px{
    padding-top: 10px;
  }  
  .myred{
    color: #f00;
    font-size: 12px;
  }
  .myMarginBottom_10px{
    margin-bottom: 10px;
  }
  .myLeftMsg{
    line-height: 40px;
    text-align: right;
  }
  .myVA_M{
    vertical-align: middle;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border:1px solid #d8dce5;
  }
  .avatar {
    width: 178px;
    height: auto;
    display: block;
  }
  .myOV_y_400px{
    max-height: 400px;
    min-height: 200px;
    overflow-y:scroll;
    border:1px solid #f2f2f2;
  }
  .mymarginTop_10px{
    margin-top: 10px;
  }
</style>

<script>
  import { extractAreaIds , onSetArea } from '@/utils/misc';
  import { getRegion } from '@/utils/localstorage';
  import { QINIU_UP_API , QINIU_API } from '@/config/baseUrl';
  import { getQNToken } from '@/api/contentMGT';
  import { getStaffList } from '@/api/staff';
  import DeptSubMenu from '@/components/DeptSubMenu';
  import { getDeptInfo } from '@/api/dept';
  import { addAssets , getAssetsClassList , getAdminForArea , getAssetsDetail , updateAssets } from '@/api/assets';
  export default {
    data(){
      return{
        title:"资产入库",
        type:"",
        id:"",
        readonly:false,
        readonly_update:false,
        regionOptions: [],
        regionOptSelected: [],
        sourceValue:1,
        sourceOptions:[
          { label:"购入", value:1 },
          { label:"自建", value:2 },
          { label:"租赁", value:3 },
          { label:"其他", value:4 },
        ],
        datePicker:"",

        uploadUrl:QINIU_UP_API,
        QINIU_API:QINIU_API,
        postData:{
          token:""
        },
        imageUrl:"",
        saveImageUrl:"",

        dynamicValidateForm: {
          domains: []
        },

        visible:false,
        attrValue:"",

        newRoleDialogVisible:false,
        kw:"",
        dutyDlgList:[],
        dutyDlgProps: {
          children: 'children',
          label: 'user_name'
        },
        dutyDlgListLoading:false,

        deptDialogVisible:false,
        deptLoading: false,
        deptSelected: null,
        deptList:[],
        dept_info:[],
        dept_info_name:"",

        dutyName:"",
        dutyId:"",

        cateDialogVisible:false,
        code:"",
        property_name:"",
        checkCate:[],
        cate_name:"",
        cate_id:"",
        cateTree:[],
        defaultProps: {
          children: 'children',
          label: 'label'
        },
        admin_options:[],
        admin_name:"",
        admin_id:"",
        property_loc:"",
        property_money:"",
        property_warranty:"",
        year_limit:"",
        property_suppliers:"",
        property_spec:"",
        property_sn:"",
        property_unit:"",
        property_note:""

      }
    },
    components: {
      DeptSubMenu
    },
    created(){
      this.regionOptions = getRegion();
      this.regionOptSelected.push(this.regionOptions[0].value,this.regionOptions[0].children[0].value,this.regionOptions[0].children[0].children[0].value);
      this.type=this.$route.query.type;
      this.id=this.$route.query.id;
      if(this.type=="add"){
        document.title="新增资产";
        this.getToken();
      }else if(this.type=="info"){
        this.readonly=true;
        this.ongetAssetsDetail();
      }else if(this.type=="update"){
        this.getToken();
        this.ongetAssetsDetail();
        this.readonly_update=true;
      }
      
    },
    computed: {
      areaIds() {
        return extractAreaIds(this.regionOptSelected, this.regionOptions);
      }
    },
    watch: {
      areaIds(val){
        this.admin_name="";
        this.dutyName="";
        this.dutyId="";
        this.ongetAdminForArea(val);
      }
    },
    methods:{
      getToken(){//拉取七牛token
        let vm=this;
        getQNToken().then(response => {
          let res=response.data.up_token;
          vm.postData.token=res;
        }).catch(error => {
          // console.log("失败")
        })
      },
      handleAvatarSuccess(res, file) {
        this.imageUrl = URL.createObjectURL(file.raw);
        this.saveImageUrl=res.key;
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isPNG = file.type === 'image/png';
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isJPG && !isPNG) {
          this.$message.error('上传图片只能是 JPG/PNG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 2MB!');
        }
        return (isJPG || isPNG) && isLt2M;
      },
      removeDomain(item) {
        var index = this.dynamicValidateForm.domains.indexOf(item)
        if (index !== -1) {
          this.dynamicValidateForm.domains.splice(index, 1)
        }
      },
      addDomain(val) {
        this.dynamicValidateForm.domains.push({
          attr_name: val
        });
      },
      attrOK(){
        if(this.attrValue!=''){
          this.addDomain(this.attrValue);
          this.attrValue='';
          this.visible=false;
        }else{
          this.$message.info("属性名称是必填项！");
        }
      },
      onAssign(){
        this.fetchStaff();
        this.newRoleDialogVisible = true;
      },
      fetchStaff() {//获取人员列表
        let vm = this;
        this.dutyDlgListLoading = true;
        let params = {
          kw:vm.kw,
          is_fuzzy:true,
          page_num: 1,
          page_size: 10000,
          ril: 'S',
          area_id:vm.areaIds,
        };
        getStaffList(params)
        .then(response => {
          vm.dutyDlgList = response.data.rows;
          vm.dutyDlgListLoading = false;
        })
        .catch(error => {
          vm.dutyDlgListLoading = false;
        })
      },
      onChange(a,b,c){
        let vm=this;
        if(b){
          vm.$refs.dutyDlg.setCheckedKeys([]);
          vm.$refs.dutyDlg.setCheckedKeys([a.staff_id]);
        }else{
          vm.$refs.dutyDlg.setCheckedKeys([]);
        }
      },
      renderContent:function(createElement, { node, data, store }) {
        var vm = this;
        return createElement(
          'div', 
          {
            attrs:{
              style:"width:100%",
              title:`联系方式：${node.data.phone}`
            }
          },
          [
            createElement('span', node.label),
            createElement('span', 
              {attrs:{
                style:"float: right; margin-right: 20px"
              }},
              `${node.data.dept_name}`
            )
          ]
        );
      },
      onSearch(){
        this.fetchStaff();
      },
      onAssignSub(){
        let vm=this;
        var duty = vm.$refs.dutyDlg.getCheckedNodes();
        if (duty.length > 0) {
          vm.dutyName = duty[0].user_name;
          vm.dutyId = duty[0].staff_id;
        }else{
          vm.dutyName = '';
          vm.dutyId = '';
        }    
        vm.newRoleDialogVisible = false;
      },
      handleDeptClick() {
        this.deptDialogVisible = true;
        this.fetchDept();
      },
      fetchDept() {
        let vm = this;
        vm.deptLoading = true;
        getDeptInfo().then(response => {
          let res = response.data;
          vm.deptList = res;
          vm.deptLoading = false;
        })
        .catch(error => {
          vm.deptLoading = false;
        })
      },
      handleDeptDlgClick() {
        let str = this.deptSelected.split('-');
        let deptInfo={
          "id":str[0],
          "name":str[1]
        } 
        this.dept_info = deptInfo;
        this.dept_info_name= str[1];
        this.deptDialogVisible = false;
      },
      handleDeptSelect(key, keyPath) {
        this.deptSelected = key;
      },
      back(){
        this.$router.go(-1);
      },
      handleCateDlgClick(){
        this.cate_name=this.checkCate.label;
        this.cate_id=this.checkCate.cate_id;
        this.year_limit=this.checkCate.year_limit; 
        this.cateDialogVisible=false;
      },
      handleNodeClick(data){
        this.checkCate=data;
      },
      renderContentcate(createElement, { node, data, store }) {
        return createElement(
          'div', 
          {},
          [
            createElement('span', `【 ${data.code} 】 - ${data.label}`)
          ]
        );
      },
      ongetAssetsClassList(){//拉取资产分类树
        getAssetsClassList().then(response => {
          let res=response.data;
          this.cateTree=res;
        }).catch(error => {
          this.$message.error("拉取分类列表失败！" + error.response.data.error_msg);
        })
      },
      getCate(){
        this.cateDialogVisible=true;
        this.ongetAssetsClassList();
      },
      add(){//新增资产
        let vm=this;
        if(!vm.property_name || !vm.cate_id || !vm.areaIds || !vm.admin_name || !vm.datePicker || !vm.property_warranty){
          vm.$message.info("请将必填数据填写完整！");
          return;
        }
        let params={
          property_name:vm.property_name,
          cate_name:vm.cate_name,
          cate_id:vm.cate_id,
          area_id:Number(vm.areaIds),
          admin_id:vm.admin_name,
          // dept_name:vm.dept_info.name,
          // dept_id:Number(vm.dept_info.id),
          // user_name:vm.dutyName,
          // user_id:Number(vm.dutyId),
          property_loc:vm.property_loc,
          property_source:vm.sourceValue,
          property_money:Number(vm.property_money),
          bought_time:vm.datePicker,
          property_warranty:Number(vm.property_warranty),
          year_limit:Number(vm.year_limit),
          property_suppliers:vm.property_suppliers,
          property_spec:vm.property_spec,
          property_sn:vm.property_sn,
          property_unit:vm.property_unit,
          attr:vm.dynamicValidateForm.domains,
          arr_url:vm.saveImageUrl?[{'att_url':vm.saveImageUrl}]:[],
          property_note:vm.property_note
        }
        addAssets(params).then(response => {
          vm.$message.success("执行成功！");
          vm.back();
        }).catch(error => {
          vm.$message.error("执行失败！" + error.response.data.error_msg);
        })
      },
      ongetAdminForArea(area_id){
        getAdminForArea(area_id).then(response => {
          let res=response.data;
          this.admin_options=res;
        }).catch(error => {
          this.$message.error("拉取管理员列表失败！" + error.response.data.error_msg);
        })
      },
      ongetAssetsDetail(){
        let vm=this;
        getAssetsDetail(vm.id).then(response => {
          let res=response.data;
          vm.code=res.property_code;
          vm.property_name=res.property_name;
          vm.cate_name=res.cate_name;
          vm.cate_id=res.cate_id;
          vm.regionOptSelected=onSetArea(vm.regionOptions,res.area_id);
          vm.admin_name=res.admin_name;
          vm.admin_id=res.admin_id;
          vm.dept_info_name=res.dept_name;
          vm.dept_info.id=res.dept_id;
          vm.dept_info.name=res.dept_name;
          vm.dutyName=res.user_name;
          vm.dutyId=res.user_id;
          vm.property_loc=res.property_loc;
          vm.sourceValue=res.property_source;
          vm.property_money=res.property_money;
          vm.datePicker=res.bought_time;
          vm.property_warranty=res.property_warranty;
          vm.year_limit=res.year_limit;
          vm.property_suppliers=res.property_suppliers;
          vm.property_spec=res.property_spec;
          vm.property_sn=res.property_sn;
          vm.property_unit=res.property_unit;
          vm.dynamicValidateForm.domains=res.attr;
          vm.imageUrl=QINIU_API+res.arr_url[0].att_url;
          vm.saveImageUrl=res.arr_url[0].att_url;
          vm.property_note=res.property_note;
        }).catch(error => {
          vm.$message.error("拉取资产详细失败！" + error.response.data.error_msg);
        })
      },
      update(){//编辑
        let vm=this;
        if(!vm.property_name || !vm.cate_id || !vm.areaIds || !vm.admin_name || !vm.datePicker || !vm.property_warranty){
          vm.$message.info("请将必填数据填写完整！");
          return;
        }
        let params={
          property_name:vm.property_name,
          cate_name:vm.cate_name,
          cate_id:vm.cate_id,
          area_id:Number(vm.areaIds),
          admin_id:Number(vm.admin_id),
          admin_name:vm.admin_name,
          // dept_name:vm.dept_info.name,
          // dept_id:Number(vm.dept_info.id),
          // user_name:vm.dutyName,
          // user_id:Number(vm.dutyId),
          property_loc:vm.property_loc,
          property_source:vm.sourceValue,
          property_money:Number(vm.property_money),
          bought_time:vm.datePicker,
          property_warranty:Number(vm.property_warranty),
          year_limit:Number(vm.year_limit),
          property_suppliers:vm.property_suppliers,
          property_spec:vm.property_spec,
          property_sn:vm.property_sn,
          property_unit:vm.property_unit,
          attr:vm.dynamicValidateForm.domains,
          arr_url:vm.saveImageUrl?[{'att_url':vm.saveImageUrl}]:[],
          property_note:vm.property_note
        }
        updateAssets(vm.id,params).then(response => {
          vm.$message.success("执行成功！");
          vm.back();
        }).catch(error => {
          console.log(error)
          vm.$message.error("执行失败！" + error.response.data.error_msg);
        })
      }

    }
}
</script>

